import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description: 栈的压入 弹出序列
 * User: liangyuanzhang
 * Date: 2025-3-24
 * Time: 23:25
 */
public class Test {
    public boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for(int i = 0;i<pushV.length;i++){
            stack.push(pushV[i]);
            while(j < popV.length && !stack.empty() && stack.peek() == popV[j]){
                stack.pop();
                j++;
            }
        }
        return stack.empty();
    }
}
